home *** CD-ROM | disk | FTP | other *** search
- //
- // File: InstaCompOneSCVersExt.c
- //
- // This file contains the source code for the DirectCopy Vers Info
- // ScriptCheck extension function. Since our source files are in the regular
- // format (not compressed or otherwise changed and unreadable by normal
- // means) we can get the version information directly from the 'vers' (1)
- // resource. In this example, we assume that we cannot get version information
- // from a source resource, and, if our source data is determined to be a resource,
- // we simply return an fnfErr. Returning any other result besides noErr tells
- // ScriptCheck to use the information from the actual source file found on the
- // source disk and disregard any information passed back through the parameter block.
- //
- // Copyright: © 1996 by Apple Computer, Inc., all rights reserved.
- //
- //
-
-
-
- #include "TargetVersMgt.h"
-
- #include <Errors.h>
- #include <Files.h>
- #include <Resources.h>
-
- OSErr main( TargetVersPBPtr theTargetVersPBPtr )
- {
- OSErr theErr = noErr;
- short savedResFile = CurResFile();
- Handle theResourceHdl;
- SInt16 fileRefNum;
-
- if( theTargetVersPBPtr->fFileVers.fSrcDataType // If we are looking at a resource
- == kVersTypeIsRsrc )
- {
- theErr = fnfErr; // This depends on the resource format, and cannot be generic.
- }
- else
- {
- // open source file to make it cur res file
- fileRefNum = HOpenResFile( theTargetVersPBPtr->fFileVers.fSrcFSSpec.vRefNum,
- theTargetVersPBPtr->fFileVers.fSrcFSSpec.parID,
- theTargetVersPBPtr->fFileVers.fSrcFSSpec.name,
- fsRdPerm );
- theErr = ResError();
- if (theErr != noErr) return theErr;
- // get a handle to our resource
- theResourceHdl = Get1Resource( 'vers', 1);
-
- theErr = ResError();
- if (theErr != noErr) return theErr;
-
- theTargetVersPBPtr->fFileVers.fTgtVersionNum = **((long**) theResourceHdl); // copy first long of vers 1
- // this is our vers in BCD format
- CloseResFile( fileRefNum );
- UseResFile( savedResFile );
-
- }
-
- return theErr;
- }